package org.robotlegs.demos.helloflex
{
	import flash.display.DisplayObjectContainer;
	import flash.display.SimpleButton;
	
	import org.robotlegs.demos.helloflex.controller.SystemEvent;
	import org.robotlegs.demos.helloflex.controller.TryClearMessages;
	import org.robotlegs.demos.helloflex.mediator.ClearMessagesButtonMediator;
	import org.robotlegs.demos.helloflex.mediator.HelloFormMediator;
	import org.robotlegs.demos.helloflex.mediator.LoginPageMediator;
	import org.robotlegs.demos.helloflex.mediator.LogoutButtonMediator;
	import org.robotlegs.demos.helloflex.mediator.MessageListMediator;
	import org.robotlegs.demos.helloflex.mediator.SimpleLogBoxMediator;
	import org.robotlegs.demos.helloflex.model.MessageModel;
	import org.robotlegs.demos.helloflex.model.UserProxy;
	import org.robotlegs.demos.helloflex.services.DummyAuthService;
	import org.robotlegs.demos.helloflex.services.IAuthService;
	import org.robotlegs.demos.helloflex.view.ClearMessagesButton;
	import org.robotlegs.demos.helloflex.view.HelloForm;
	import org.robotlegs.demos.helloflex.view.LoginPage;
	import org.robotlegs.demos.helloflex.view.LogoutButton;
	import org.robotlegs.demos.helloflex.view.MessageList;
	import org.robotlegs.mvcs.Context;
	
	public class HelloFlexContext extends Context
	{
		public function HelloFlexContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
		{
			super(contextView, autoStartup);
		}
		
		override public function startup():void
		{
			commandMap.mapEvent(SystemEvent.CLEAR_MESSAGES_REQUESTED, TryClearMessages);
			
			injector.mapSingleton(UserProxy);
			injector.mapSingleton(MessageModel);
			injector.mapSingletonOf(IAuthService, DummyAuthService);
			
			mediatorMap.mapView(HelloForm, HelloFormMediator);
			mediatorMap.mapView(MessageList, MessageListMediator);
			mediatorMap.mapView(ClearMessagesButton, ClearMessagesButtonMediator);
			mediatorMap.mapView(LoginPage, LoginPageMediator);
			mediatorMap.mapView(LogoutButton, LogoutButtonMediator);
			mediatorMap.mapView(SimpleButton, SimpleLogBoxMediator);
			
			super.startup();
			
		}
	}

}